package com.trade.utils;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;

/**
 * Created by Administrator on 2016/10/15.
 */
public class HibernateUtil {

    private static final SessionFactory factory;
    static {
//        //读取配置文件
//        Configuration cfg = new Configuration().configure();

        factory = new AnnotationConfiguration().configure().buildSessionFactory();

    }

    public static Session getSession()
            throws HibernateException {
        return factory.openSession();
    }
}
